package com.zpark.service.Impl;


import com.zpark.mapper.IRankingMapper;
import com.zpark.pojo.Ranking;
import com.zpark.service.IRankingRepositoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

@Service
public class RankingRepositoryServiceImpl implements IRankingRepositoryService {

    @Autowired
    private IRankingMapper rankingMapper;


    @Override
    public List<Ranking> findAll() {
        return rankingMapper.findAll();
    }

    @Override
    public Optional<Ranking> findById(Integer id) {
        return rankingMapper.findById(id);
    }


    @Override
    public void remove(Integer id) {
        rankingMapper.deleteById(id);
    }

    @Override
    public void change(Ranking ranking) {
        rankingMapper.save(ranking);
    }

    @Override
    public void add(Ranking ranking) {
        rankingMapper.save(ranking);
    }

    @Override
    public Page<Ranking> findPage(Integer startPage, Integer size) {
        return rankingMapper.findAll(PageRequest.of(startPage,size));
    }

    @Override
    public List<Ranking> findByMovieName(String filmName) {
        return rankingMapper.findByfilmName(filmName);
    }
}
